package com.bestow.basic.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bestow.common.annotation.Log;
import com.bestow.common.core.controller.BaseController;
import com.bestow.common.core.domain.AjaxResult;
import com.bestow.common.enums.BusinessType;
import com.bestow.basic.domain.FndTaxTypeCode;
import com.bestow.basic.service.IFndTaxTypeCodeService;
import com.bestow.common.utils.poi.ExcelUtil;
import com.bestow.common.core.page.TableDataInfo;

/**
 * 税种定义Controller
 * 
 * @author liliu
 * @date 2022-09-07
 */
@RestController
@RequestMapping("/basic/fndTaxTypeCode")
public class FndTaxTypeCodeController extends BaseController
{
    @Autowired
    private IFndTaxTypeCodeService fndTaxTypeCodeService;

    /**
     * 查询税种定义列表
     */
    @PreAuthorize("@ss.hasPermi('basic:fndTaxTypeCode:list')")
    @GetMapping("/list")
    public TableDataInfo list(FndTaxTypeCode fndTaxTypeCode)
    {
        startPage();
        List<FndTaxTypeCode> list = fndTaxTypeCodeService.selectFndTaxTypeCodeList(fndTaxTypeCode);
        return getDataTable(list);
    }

    /**
     * 导出税种定义列表
     */
    @PreAuthorize("@ss.hasPermi('basic:fndTaxTypeCode:export')")
    @Log(title = "税种定义", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FndTaxTypeCode fndTaxTypeCode)
    {
        List<FndTaxTypeCode> list = fndTaxTypeCodeService.selectFndTaxTypeCodeList(fndTaxTypeCode);
        ExcelUtil<FndTaxTypeCode> util = new ExcelUtil<FndTaxTypeCode>(FndTaxTypeCode.class);
        util.exportExcel(response, list, "税种定义数据");
    }

    /**
     * 获取税种定义详细信息
     */
    @PreAuthorize("@ss.hasPermi('basic:fndTaxTypeCode:query')")
    @GetMapping(value = "/{taxTypeCode}")
    public AjaxResult getInfo(@PathVariable("taxTypeCode") String taxTypeCode)
    {
        return AjaxResult.success(fndTaxTypeCodeService.selectFndTaxTypeCodeByTaxTypeCode(taxTypeCode));
    }

    /**
     * 新增税种定义
     */
    @PreAuthorize("@ss.hasPermi('basic:fndTaxTypeCode:add')")
    @Log(title = "税种定义", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FndTaxTypeCode fndTaxTypeCode)
    {
        return toAjax(fndTaxTypeCodeService.insertFndTaxTypeCode(fndTaxTypeCode));
    }

    /**
     * 修改税种定义
     */
    @PreAuthorize("@ss.hasPermi('basic:fndTaxTypeCode:edit')")
    @Log(title = "税种定义", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FndTaxTypeCode fndTaxTypeCode)
    {
        return toAjax(fndTaxTypeCodeService.updateFndTaxTypeCode(fndTaxTypeCode));
    }

    /**
     * 删除税种定义
     */
    @PreAuthorize("@ss.hasPermi('basic:fndTaxTypeCode:remove')")
    @Log(title = "税种定义", businessType = BusinessType.DELETE)
	@DeleteMapping("/{taxTypeCodes}")
    public AjaxResult remove(@PathVariable String[] taxTypeCodes)
    {
        return toAjax(fndTaxTypeCodeService.deleteFndTaxTypeCodeByTaxTypeCodes(taxTypeCodes));
    }
}
